var Obj = window.loadI18n('base/user');
$.alert = function(json,upfun){
	this.options = {
			title:""+Obj.get('base.common.success.Systemprompt')+"",
			mode:true,
			content:"Hello World",
			btns:[{text:""+Obj.get('base.common.success.sure')+"",click:function(){
				$(".div_alert").hide();
				if(upfun){
					upfun();
				}
			}}],
	};
	if(typeof json == "string"){
		this.options.content = json;
	}
	if(json == undefined){
		return this;
	}else if(typeof json == "object"){
		for(var key in json){
		   this.options[key]=json[key];
		}
		var createBtn = function(ja){
			for(var i in ja){
				$("#btns_div").append("<button class='applybtn'  id='btn_"+i+"'>"+ja[i].text+"</button>");
				for(var key in ja[i]){
					if(typeof ja[i][key]=="function"){
						$("#btn_"+i).bind(key,ja[i][key]);
					}
				}
			}	
		}
		var create = function(opt){
			try{
				$(".div_alert").remove();
				if(opt.mode){
					$("body").first().prepend("<div class='div_alert tipstyle'></div>");
				}else{
					$("body").first().prepend("<div class='div_alert'></div>");
				}
				$(".div_alert").append("<div class='logintiptext'>"+
							"<h1 class='t_css'>"+opt.title+"</h1>"+
							"<p class='c_css'>"+opt.content+"</p>"+
							"<div id='btns_div'></div></div>");
				createBtn(opt.btns);
			}catch(e){alert(e);};
		}
		create(this.options);
		return this;
	}
}
